const webpack = require('webpack');
const path = require('path');
const ExtractTextPlugin = require('extract-text-webpack-plugin');


const main = new ExtractTextPlugin('css/[name].css');
const main2 = new ExtractTextPlugin('css/[name].css');
module.exports = {
  entry: {// 入口文件
      comp: './comp.js',
      index: './index.js'
  },
  output: { // 出口文件
    path: path.resolve(__dirname, './dist/'),
    publicPath: './',
    filename: 'js/[name].js'
  },
  module: {
    rules: [{
        test: /\.js$/,
        use: {
          loader: 'babel-loader',
          options: {
            presets: ['env']
          }
        }
      },
      {
        test: /\.[s]css$/,
        use: ExtractTextPlugin.extract({
          fallback: 'style-loader',
          loader: 'css-loader!sass-loader!postcss-loader'
        })
      },{
        test: /\.(gif|jpg|png|woff|svg|eot|ttf)\??.*$/,
        use: {
          loader: 'url-loader?limit=8192&name=img/[hash:8].[name].[ext]'
        }
      },
    ]
  },
  plugins: [
    // new ExtractTextPlugin('css/style.css') // 提取css
      main,
      main2
  ]
}
